#ifndef JSONHANDLE_H
#define JSONHANDLE_H

#include <QObject>
#include "common.h"
class QPlainTextEdit;

class JsonHandle {
public:
    explicit JsonHandle(QPlainTextEdit *p_text_edit = nullptr);
    ~JsonHandle();

    bool jsonScan(QString file_name, QString gen_url);
    QStringList getFileTree();
    QStringList getFolderTree();
    QList<CopyTree> getFileCTree();
    QList<CopyTree> getFolderCTree();

private:
    QPlainTextEdit *w;

    QStringList folder_tree,
                file_tree;
    QList<CopyTree> file_ctree,
                    folder_ctree;

    QByteArray getJsonData(QString file_name);
    QJsonDocument jsonParse(QByteArray json);
    void jsonErgodic(QJsonDocument &json_doc, QString args);
    void jsonObjLoop(QJsonObject &json_obj, QString &args, int deep);
    void jsonArrLoop(QJsonArray &json_arr, QString key, QString &args, int deep);
    void jsonValLoop(QJsonValue &json_val, QString key, QString &args, int deep);
};

#endif // JSONHANDLE_H
